<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<div>
	<input id="casesId" name="casesId" type="hidden" value="${scenario.cases.casesId}">
	<input id="scenarioId" name="scenarioId" type="hidden" value="${scenario.scenarioId}">
	<table>
			<tr>
				<th width="75px">编码</th>
				<td>
					${scenario.scenarioCode}
				</td>
			</tr>
			<tr>
				<th width="75px">场景标题</th>
				<td>
					${scenario.title}
				</td>
			</tr>
			<tr>
				<th width="75px">场景内容</th>
				<td>
					${scenario.content}
				</td>
			</tr>
			<tr>
				<th width="75px"> 场景使用的图片路径</th>
				<td>
					<img src="${scenario.image}">
				</td>
			</tr>
			<tr>
				<th width="75px">场景的位置</th>
				<td>
					<select name="scenario.position">
						<option value="1" <c:if test="${scenario.position ==1}">selected="selected"</c:if>>开始</option>
						<option value="-1" <c:if test="${scenario.position ==-1}">selected="selected"</c:if>>结束</option>
						<option value="0" <c:if test="${scenario.position ==0}">selected="selected"</c:if>>中间</option>
					</select>
				</td>
			</tr>
			<tr>
				<th width="75px">是否是正确的结束</th>
				<td>
					<select name="scenario.answer">
						<option value="1" <c:if test="${scenario.answer ==1}">selected="selected"</c:if>>正确</option>
						<option value="-1" <c:if test="${scenario.answer ==-1}">selected="selected"</c:if>>错误</option>
						<option value="0" <c:if test="${scenario.answer ==0}">selected="selected"</c:if>>不是结束</option>
					</select>
				</td>
			</tr>
			<tr>
				<th width="75px">是否可用</th>
				<td>
					<c:if test="${scenario.enabled ==1}">可用</c:if>
					<c:if test="${scenario.enabled ==11}">不可用</c:if>
				</td>
			</tr>
	</table>
	<table>
		<tr>
			<td>
				<table>
					<tr>
						<td>动作</td>
					</tr>
					<tr>
						<td>
							<select id="actionIds" name="actionIds" size="10">
								<c:if test="${not empty actions}">
								<c:forEach var="actionx" items="${actions}">
									<option value="${actionx.actionId}"><c:out value="${actionx.actionName}"/></option>
								</c:forEach>
								</c:if>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<button onclick="createAction()">创建动作</button>
							<button onclick="deleteAction()">删除动作</button>
						</td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td>动作对象</td>
					</tr>
					<tr>
						<td>
							<select id="targetIds" name="targetIds" size="10">
								<c:if test="${not empty targets}">
									<c:forEach var="targetx" items="${targets}">
										<option value="${targetx.targetId}"><c:out value="${targetx.targetName}"/></option>
									</c:forEach>
								</c:if>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<button onclick="createTarget()">创建对象</button>
							<button onclick="deleteTarget()">删除对象</button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<button onclick="createScenario()">创建新场景</button>
				<a href="${ctx}/admin/cases/scenario/index.do?casesId=${scenario.cases.casesId}">场景列表</a>
			</td>
		</tr>
	</table>
</div>
<script>
function createAction(){
	window.location.href = ctx + "/admin/cases/action/create.do?scenarioId=" + $("#scenarioId").val();
}
function deleteAction(){
	window.location.href = ctx + "/admin/cases/action/delete.do?actionId=" + $("#actionIds").val()+"&scenarioId=" + $("#scenarioId").val();
}

function createTarget(){
	window.location.href = ctx + "/admin/cases/target/create.do?scenarioId=" + $("#scenarioId").val();
}
function deleteTarget(){
	window.location.href = ctx + "/admin/cases/target/delete.do?targetId=" + $("#targetIds").val()+"&scenarioId=" + $("#scenarioId").val();
}
function createScenario(){
	var actionId = $("#actionIds").val();
	var targetId = $("#targetIds").val();
	if(actionId == null || targetId == null){
		alert("请选择一个动作 和一个对象");
		return ;
	}
	window.location.href = ctx + "/admin/cases/scenario/create.do?casesId=" + $("#casesId").val() + "&actionId="+ actionId +"&targetId="+targetId;
}
</script>